package edu.sctu.practice.class02.xuejiahua.practise.test04;

/**
 * Created by Dom_xuejiahua on 2015/12/13.
 */
public class ChainTest {
    /*
    * test1():抛出 “喝大了” 异常
    * test2():调用test1(),捕获“喝大了”异常，并且包装成运行时异常，继续抛出
    * 在main方法中，调用test2(),尝试捕获test2()方法抛出异常
    *
    * */


    public void test1()throws  DrunkException{
        throw  new DrunkException("喝车别开酒");

    }

    public void test2(){
        try{
            test1();
        }catch (DrunkException e){
            RuntimeException newExc =
                    new RuntimeException("司机一滴酒，就成天堂狗");
            newExc.initCause(e);
            throw newExc;

        }
    }

}
